<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/TR/xhtml1/strict">
<head>
<title>Apache HowTo</title>
<!--
   Copyright 1999-2004 The Apache Software Foundation
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<meta content="1999-2004 The Apache Software Foundation" name="copyright"/>
<meta content="$Date$" name="last-changed"/>
<meta content="Henri Gomez" name="author"/>
<meta content="hgomez@apache.org" name="email"/>
<meta content="Gal Shachor" name="author"/>
<meta content="shachor@il.ibm.com" name="email"/>
<link href="..//style.css" type="text/css" rel="stylesheet"/>
<link href="../images/tomcat.ico" rel="shortcut icon"/>
</head>
<body link="#525D76" vlink="#525D76" alink="#525D76" text="#000000" bgcolor="#ffffff">
<a name="TOP"/>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr height="1">
<td class="nil" height="1" bgcolor="#ffffff" width="150">
<img hspace="0" vspace="0" height="1" width="150" border="0" src="../images/pixel.gif"/>
</td>
<td class="nil" height="1" bgcolor="#ffffff" width="*">
<img hspace="0" vspace="0" height="1" width="370" border="0" src="../images/pixel.gif"/>
</td>
</tr>
<tr>
<td width="*" colspan="2" class="logo" bgcolor="#ffffff">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left">
<img align="left" height="48" width="505" border="0" src="../images/jakarta.gif"/>
</td>
<td align="right">
<img align="right" border="0" src="../images/mod_jk.jpg"/>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2" width="*" align="right" class="head" bgcolor="#999999">
<nobr>
<a href="http://www.apache.org/" class="head">Apache Software Foundation</a> |
                <a href="http://jakarta.apache.org/" class="head">Jakarta Project</a> |
                <a href="http://jakarta.apache.org/tomcat/" class="head">Apache Tomcat</a>
</nobr>
</td>
</tr>
<tr>
<td valign="top" width="150" bgcolor="#ffffff">
<table class="menu" cellpadding="0" cellspacing="0" width="150" border="0">
<tr height="1">
<td class="nil" height="1" bgcolor="#cccccc" width="10">
<img hspace="0" vspace="0" height="1" width="10" border="0" src="../images/pixel.gif"/>
</td>
<td class="nil" height="1" bgcolor="#cccccc" width="140">
<img hspace="0" vspace="0" height="1" width="140" border="0" src="../images/pixel.gif"/>
</td>
</tr>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Presentation</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../index.html">Overview</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Commons</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/AJPv13.html">AJPv13</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/AJPv13-extensions-proposal.html">AJPv13 extensions Proposal</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/doccontrib.html">How to Contribute to the Documentation</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../common/tools.html">Tools</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../faq.html">FAQ</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">JK</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/quickhowto.html">Quick Start HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/aphowto.html">Apache HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Introduction" class="menu">Introduction</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Obtaining mod_jk" class="menu">Obtaining mod_jk</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Installation" class="menu">Installation</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#mod_jk Directives" class="menu">mod_jk Directives</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Building mod_jk on Unix" class="menu">Building mod_jk on Unix</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Building mod_jk for Apache on Windows NT/2K/XP" class="menu">Building mod_jk for Apache on Windows NT/2K/XP</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Building mod_jk for Apache on iSeries/OS400" class="menu">Building mod_jk for Apache on iSeries/OS400</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Building mod_jk for Apache on MacOS/X" class="menu">Building mod_jk for Apache on MacOS/X</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td width="10" bgcolor="#cccccc"/>
<td width="140" bgcolor="#cccccc">
<a href="#Getting mod_jk linked statically with Apache" class="menu">Getting mod_jk linked statically with Apache</a>
</td>
</tr>
<tr height="1"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/domhowto.html">Domino HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/iishowto.html">IIS HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/neshowto.html">Netscape/iPlanet HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk/workershowto.html">Workers HowTo</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">JK2</td>
</tr>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Configuration in the Tomcat</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtc.html">Configuration options</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtccom.html">Coyote/JK2 Handlers</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configtcex.html">Examples</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Configuration in the Web Server</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configweb.html">Configuration file</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configwebcom.html">Components</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/configwebex.html">Examples</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Installation</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/installhowto.html">Installation of jk2 in the Web Server</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
<tr height="6">
<td colspan="2" width="150" bgcolor="#d0d0d0">Howto</td>
</tr>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/confighowto.html">Quick Start JK2 Configuration Guide</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/vhosthowto.html">Apache 2.0.43 - Tomcat 4.1.12 - jk2 - virtual host HOWTO</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr>
<td colspan="2" width="150" bgcolor="#cccccc">
<nobr>
<a class="menu" href="../jk2/davhowto.html">Apache 2.x/mod-dav - Tomcat/jk2 - HOWTO</a>
</nobr>
</td>
</tr>
<tr height="2"/>
<tr height="6"/>
</table>
</td>
<td class="body" valign="top" width="*" bgcolor="#ffffff">
<a name="Introduction">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Introduction</td>
</tr>
</table>
</a>
<p class="section">
This document explains how to connect Tomcat to the popular open source web server, Apache. 
There is actually two version of Apache, 1.3 and 2.0 and both can be used with mod_jk, the Tomcat redirector
module.
</p>
<p class="section">
It is recommanded that you also read the <b>
<a href="../jk/workershowto.html">Workers HowTo</a>
</b> document
to learn how to setup the working entities between your WebServer and Tomcat Engines.
</p>
<p class="section">
This document was originally part of <b>
<font color="#333333">Tomcat: A Minimalistic User's Guide</font>
</b> written by Gal Shachor, 
but has been split off for organizational reasons. 
</p>
<a name="sub_Document Conventions and Assumptions">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Document Conventions and Assumptions</td>
</tr>
</table>
</a>
<p class="section">
${tomcat_home} is the root directory of tomcat. 
Your Tomcat installation should have the following subdirectories:

<ul>
<li>
${tomcat_home}\conf - Where you can place various configuration files
</li>
<li>
${tomcat_home}\webapps - Containing example applications
</li>
<li>
${tomcat_home}\bin - Where you place web server plugins
</li>
</ul>
</p>
<p class="section">
In all the examples in this document ${tomcat_home} will be <b>
<font color="#333333">/var/tomcat3</font>
</b>.
A <b>
<a href="../jk/workershowto.html">worker</a>
</b> is defined to be a tomcat process that accepts work from the Apache server.
</p>
<br/>
<a name="sub_Supported Configuration">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Supported Configuration</td>
</tr>
</table>
</a>
<p class="section">
The mod_jk module was developed and tested on:
<ul>
<li>
Linux, FreeBSD, AIX, HP-UX, MacOS X, and should works on major Unixes platforms supporting Apache 1.3 and/or 2.0
</li>
<li>
WinNT4.0-i386 SP4/SP5/SP6a (should be able to work with other service packs), Win2K and WinXP and Win98
</li>
<li>
Cygwin (until you have an apache server and autoconf/automake support tools)
</li>
<li>
Netware
</li>
<li>
iSeries V5R1 and V5R2 with Apache 2.0.39. Be sure to have the latest Apache PTF installed. 
</li>
<li>
Tomcat 3.2.x, Tomcat 3.3.x, Tomcat 4.0.x, Tomcat 4.1.x and Tomcat 5
</li>
</ul>
</p>
<p class="section">
The redirector uses <b>
<font color="#333333">ajp12</font>
</b> and <b>
<font color="#333333">ajp13</font>
</b> to send requests to the Tomcat containers. There is also an option to use Tomcat in process, 
more about the in-process mode can be found in the in process howto.
</p>
<br/>
<a name="sub_Who support ajp protocols ?">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Who support ajp protocols ?</td>
</tr>
</table>
</a>
<p class="section">
The ajp12 protocol is only available in Tomcat 3.2.x and 3.3.x.
</p>
<p class="section">
The <b>
<font color="#333333">ajp12</font>
</b> has been <b>
<font color="#333333">deprecated</font>
</b> with Tomcat 3.3.x and you should use instead 
<b>
<font color="#333333">ajp13</font>
</b> which is the only ajp protocol known by Tomcat 4.0.x, 4.1.x and 5.
</p>
<p class="section">
Of course Tomcat 3.2.x and 3.3.x also support ajp13 protocol.
</p>
<p class="section">
Others servlet engines such as <b>
<font color="#333333">jetty</font>
</b> have support for ajp13 protocol
</p>
<br/>
<a name="sub_How does it work ?">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>How does it work ?</td>
</tr>
</table>
</a>
<p class="section">
In a nutshell a web server is waiting for client HTTP requests. 
When these requests arrive the server does whatever is needed to serve the 
requests by providing the necessary content.
</p>
<p class="section">
Adding a servlet container may somewhat change this behavior. 
Now the web server needs also to perform the following:
</p>
<ul>
<li>
Load the servlet container adapter library and initialize it (prior to serving requests).
</li>
<li>
When a request arrives, it needs to check and see if a certain request belongs to a servlet, 
if so it needs to let the adapter take the request and handle it.
</li>
</ul>
<p class="section">
The adapter on the other hand needs to know what requests it is going to serve, 
usually based on some pattern in the request URL, and to where to direct these requests.
</p>
<p class="section">
Things are even more complex when the user wants to set a configuration that uses virtual hosts, 
or when they want multiple developers to work on the same web server 
but on different servlet container JVMs. 
We will cover these two cases in the advanced sections. 
</p>
<br/>
<br/>
<a name="Obtaining mod_jk">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Obtaining mod_jk</td>
</tr>
</table>
</a>
<p class="section">
mod_jk can be obtained in two formats - binary and source.  
Depending on the platform you are running your web server on, a binary version of mod_jk may be available.  
</p>
<p class="section">
It is recommended to use the binary version if one is available.  
If the binary is not available, follow the instructions for building mod_jk from source.  
The mod_jk source can be downloaded from a mirror
<b>
<a href="http://jakarta.apache.org/site/sourceindex.cgi/">
here</a>
</b>
</p>
<p class="section">
The binaries for mod_jk are now available, for several platforms, in a separate area as the Tomcat Binary Release.  
The binaries are located in subdirectories by platform.  
</p>
<p class="section">
For some platforms, such as Windows, this is the typical way of obtaining mod_jk 
since most Windows systems do not have C compilers.
</p>
<p class="section">
For others, the binary distribution of mod_jk offers simpler installation.
</p>
<p class="section">
For example JK 1.2.5 can be downloaded from a mirror
<b>
<a href="http://jakarta.apache.org/site/binindex.cgi/">
here</a>
</b> and contains binary version for a variety of
operating systems for both Apache 1.3 and Apache 2.
</p>
<br/>
<a name="Installation">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Installation</td>
</tr>
</table>
</a>
<p class="section">
mod_jk requires two entities:

<ul>
<li>
<b>
<font color="#333333">mod_jk.xxx</font>
</b> - The Apache module, depending on your operating system, it will be mod_jk.so, mod_jk.dll, mod_jk,nlm or 
or QZTCJK.SRVPGM (see the build section).
</li>
<li>
<b>
<font color="#333333">workers.properties</font>
</b> - A file that describes the host(s) and port(s) used by the workers (Tomcat processes). 
A sample workers.properties can be found under the conf directory.
</li>
</ul>
</p>
<p class="section">
Also as with other Apache modules, mod_jk should be first installed on the modules directory of your
Apache webserver, ie : /usr/lib/apache and you should update your <b>
<font color="#333333">httpd.conf</font>
</b> file.
</p>
<a name="sub_Disabling old mod_jserv">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Disabling old mod_jserv</td>
</tr>
</table>
</a>
<p class="section">
If you've previously configured Apache to use <b>
<font color="#333333">mod_jserv</font>
</b>, remove any <b>
<font color="#333333">ApJServMount</font>
</b> directives 
from your httpd.conf. 
</p>
<p class="section">If you're including <b>
<font color="#333333">tomcat-apache.conf</font>
</b> or <b>
<font color="#333333">tomcat.conf</font>
</b>, you'll want to remove them as well - 
they are specific to <b>
<font color="#333333">mod_jserv</font>
</b>.  
</p>
<p class="section">
The mod_jserv configuration directives are not compatible with mod_jk !
</p>
<br/>
<a name="sub_Using Tomcat auto-configure">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Using Tomcat auto-configure</td>
</tr>
</table>
</a>
<p class="section">
The simplest way to configure Apache to use mod_jk is to turn on the Apache auto-configure setting 
in Tomcat and put the following include directive at the end of your Apache httpd.conf file 
(make sure you replace TOMCAT_HOME with the correct path for your Tomcat installation:
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen">To be added at the end of your httpd.conf</div>
<code class="screen">
<nobr>Include /var/tomcat3/conf/jk/mod_jk.conf-auto</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
This will tell Apache to use directives in the <b>
<font color="#333333">mod_jk.conf-auto</font>
</b> file in the Apache configuration.  
This file is created by enabling the Apache auto-configuration as described in the Tomcat documentation.
</p>
<br/>
<a name="sub_Custom mod_jk configuration">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Custom mod_jk configuration</td>
</tr>
</table>
</a>
<p class="section">
You should use custom configuration when :
</p>
<ul>
<li>
You couldn't use <b>
<font color="#333333">mod_jk.conf-auto</font>
</b> since Tomcat engine isn't on the same machine that your Apache WebServer, 
ie when you have an Apache in front of a Tomcat Farm.
</li>
<li>
Another case for custom configuration is when your Apache is in front of many differents Tomcat engines,
each one having it's own configuration, a general case in ISP hosting
</li>
<li>
Also all Apache webmaster will retain custom configuration to be able to tune the settings
to their real needs.
</li>
</ul>
<br/>
<a name="sub_Simple configuration example">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Simple configuration example</td>
</tr>
</table>
</a>
<p class="section">
Here is a simple configuration:
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"># Load mod_jk module</div>
<code class="screen">
<nobr>LoadModule    jk_module  libexec/mod_jk.so</nobr>
</code>
<br/>
<div class="screen"># Declare the module for &lt;IfModule directive&gt;</div>
<code class="screen">
<nobr>AddModule     mod_jk.c</nobr>
</code>
<br/>
<div class="screen"># Where to find workers.properties</div>
<code class="screen">
<nobr>JkWorkersFile /etc/httpd/conf/workers.properties</nobr>
</code>
<br/>
<div class="screen"># Where to put jk logs</div>
<code class="screen">
<nobr>JkLogFile     /var/log/httpd/mod_jk.log</nobr>
</code>
<br/>
<div class="screen"># Set the jk log level [debug/error/info]</div>
<code class="screen">
<nobr>JkLogLevel    info</nobr>
</code>
<br/>
<div class="screen"># Select the log format</div>
<code class="screen">
<nobr>JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "</nobr>
</code>
<br/>
<div class="screen"># JkOptions indicate to send SSL KEY SIZE, </div>
<code class="screen">
<nobr>JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories</nobr>
</code>
<br/>
<div class="screen"># JkRequestLogFormat set the request format </div>
<code class="screen">
<nobr>JkRequestLogFormat     "%w %V %T"</nobr>
</code>
<br/>
<div class="screen"># Send servlet for context /examples to worker named worker1</div>
<code class="screen">
<nobr>JkMount  /examples/servlet/* worker1</nobr>
</code>
<br/>
<div class="screen"># Send JSPs  for context /examples to worker named worker1</div>
<code class="screen">
<nobr>JkMount  /examples/*.jsp worker1</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
<a name="mod_jk Directives">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>mod_jk Directives</td>
</tr>
</table>
</a>
<p class="section">
We'll discuss here the mod_jk directives and details behind them
</p>
<a name="sub_Define workers">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Define workers</td>
</tr>
</table>
</a>
<p class="section">
<b>
<font color="#333333">JkWorkersFile</font>
</b> specify the location where mod_jk will find the workers definitions.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkWorkersFile     /etc/httpd/conf/workers.properties</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<br/>
<a name="sub_Logging">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Logging</td>
</tr>
</table>
</a>
<p class="section">
<b>
<font color="#333333">JkLogFile</font>
</b> specify the location where mod_jk is going to place its log file.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkLogFile     /var/log/httpd/mod_jk.log</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<p class="section">
<b>
<font color="#333333">JkLogLevel</font>
</b>
set the log level between :
</p>
<ul>
<li>
<b>
<font color="#333333">info</font>
</b> log will contains standard mod_jk activity (default).
</li>
<li>
<b>
<font color="#333333">error</font>
</b> log will contains also error reports.
</li>
<li>
<b>
<font color="#333333">debug</font>
</b> log will contains all informations on mod_jk activity
</li>
</ul>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkLogLevel    info</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
<b class="code">info</b> should be your default selection for normal operations.
<br/>
<br/>
</p>
<p class="section">
<b>
<font color="#333333">JkLogStampFormat</font>
</b> will configure the date/time format found on mod_jk logfile. 
Using the strftime() format string it's set by default to <b>
<font color="#333333">"[%a %b %d %H:%M:%S %Y]"</font>
</b>
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
<br/>
<br/>
</p>
<p class="section">
<b>
<font color="#333333">JkRequestLogFormat</font>
</b> will configure the format of mod_jk individual request logging. 
Request logging is configured and enabled on a per virtual host basis. 
To enable request logging for a virtual host just add a JkRequestLogFormat config. 
The syntax of the format string is similiar to the Apache LogFormat command, 
here is a list of the available request log format options:
</p>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Options</td>
<td align="middle" valign="top" bgcolor="#039acc">Description</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%b</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Bytes sent, excluding HTTP headers (CLF format)</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%B</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Bytes sent, excluding HTTP headers</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%H</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The request protocol</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%m</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The request method</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%p</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The canonical Port of the server serving the request</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%q</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The query string (prepended with a ? if a query string exists, otherwise an empty string)</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%r</td>
<td align="left" valign="top" bgcolor="#a0ddf0">First line of request</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%s</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Request HTTP status code</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%T</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Request duration, elapsed time to handle request in seconds '.' micro seconds</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%U</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The URL path requested, not including any query string.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%v</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The canonical ServerName of the server serving the request</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%V</td>
<td align="left" valign="top" bgcolor="#a0ddf0">The server name according to the UseCanonicalName setting</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">%w</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Tomcat worker name</td>
</tr>
</table>

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkRequestLogFormat     "%w %V %T"</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<br/>
<a name="sub_Forwarding">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Forwarding</td>
</tr>
</table>
</a>
<p class="section">
The directive JkOptions allow you to set many forwarding options which will enable (+)
or disable (-) following option.
<br/>
<br/>
</p>
<p class="section">
JkOptions <b>
<font color="#333333">ForwardKeySize</font>
</b>,  you ask mod_jk, when using ajp13, to forward also the SSL Key Size  as 
required by Servlet API 2.3.
This flag shouldn't be set when servlet engine is Tomcat 3.2.x (on by default).

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkOptions     +ForwardKeySize</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<p class="section">
JkOptions <b>
<font color="#333333">ForwardURICompat</font>
</b>, you told mod_jk to send the URI to Tomcat normally, 
which is less spec compliant but mod_rewrite compatible, 
use it for compatibility with Tomcat 3.2.x engines (on by default).

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkOptions     +ForwardURICompat</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<p class="section">
JkOptions <b>
<font color="#333333">ForwardURICompatUnparsed</font>
</b>, the forwarded URI 
is unparsed, it's spec compliant but broke mod_rewrite.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkOptions     +ForwardURICompatUnparsed</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<p class="section">
JkOptions <b>
<font color="#333333">ForwardURIEscaped</font>
</b>, the forwarded URI is escaped and 
Tomcat (since 3.3 rc2) will do the decoding part.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkOptions     +ForwardURIEscaped</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>

<br/>
<br/>
</p>
<p class="section">
JkOptions <b>
<font color="#333333">ForwardDirectories</font>
</b> is used in conjunction with <b>
<font color="#333333">DirectoryIndex</font>
</b> 
directive of Apache web server. As such mod_dir should be available to Apache,
statically or dynamically (DSO)
<br/>
<br/>
</p>
<p class="section">
When DirectoryIndex is configured, Apache will create sub-requests for
each of the local-url's specified in the directive, to determine if there is a
local file that matches (this is done by stat-ing the file).
</p>
<p class="section">
If ForwardDirectories is set to false (default) and Apache doesn't find any
files that match, Apache will serve the content of the directory (if directive
Options specifies Indexes for that directory) or a <b class="code">403 Forbidden</b> response (if
directive Options doesn't specify Indexes for that directory).
</p>
<p class="section">
If ForwarDirectories is set to true and Apache doesn't find any files that
match, the request will be forwarded to Tomcat for resolution. This is used in
cases when Apache cannot see the index files on the file system for various
reasons: Tomcat is running on a different machine, the JSP file has been
precompiled etc. 
</p>
<p class="section">Note that locally visible files will take precedence over the
ones visible only to Tomcat (i.e. if Apache can see the file, that's the one
that's going to get served). This is important if there is more then one type of
file that Tomcat normally serves - for instance Velocity pages and JSP pages.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkOptions     +ForwardDirectories</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
</p>
<p class="section">
The directive <b>
<font color="#333333">JkEnvVar</font>
</b> allow you to forward an environment vars from Apache server to Tomcat engine.

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code class="screen">
<nobr>JkEnvVar     SSL_CLIENT_V_START</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
</p>
<br/>
<a name="sub_Assigning URLs to Tomcat">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Assigning URLs to Tomcat</td>
</tr>
</table>
</a>
<p class="section">
If you have created a custom or local version of mod_jk.conf-local as noted above, 
you can change settings such as the workers or URL prefix.
</p>
<p class="section">
<b>
<font color="#333333">JkMount</font>
</b> directive assign specific URLs to Tomcat. 
In general the structure of a JkMount directive is:
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"># send all requests ending in .jsp to worker1</div>
<code class="screen">
<nobr>JkMount /*.jsp worker1</nobr>
</code>
<br/>
<div class="screen"># send all requests ending /servlet to worker1</div>
<code class="screen">
<nobr>JkMount /*/servlet/ worker1</nobr>
</code>
<br/>
<div class="screen"># send all requests jsp requests to files located in /otherworker will go worker2</div>
<code class="screen">
<nobr>JkMount /otherworker/*.jsp worker2</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
You can use the JkMount directive at the top level or inside &lt;VirtualHost&gt; sections of your httpd.conf file.
</p>
<br/>
<a name="sub_Configuring Apache to serve static web application files">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Configuring Apache to serve static web application files</td>
</tr>
</table>
</a>
<p class="section">
If the Tomcat Host appBase (webapps) directory is accessible by the Apache web server, 
Apache can be configured to serve web application context directory static files instead 
of passing the request to Tomcat.
</p>
<p class="section">
Caution: If Apache is configured to serve static pages for a web application it bypasses 
any security contraints you may have configured in your web application web.xml config file.
</p>
<p class="section">Use Apache's <b>
<font color="#333333">Alias</font>
</b> directive to map a single web application context directory into Apache's 
document space for a VirtualHost:
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"># Static files in the examples webapp are served by apache</div>
<code class="screen">
<nobr>Alias /examples /vat/tomcat3/webapps/examples</nobr>
</code>
<br/>
<div class="screen"># The following line prohibits users from directly access WEB-INF</div>
<code class="screen">
<nobr>&lt;Location "/examples/WEB-INF/"&gt;</nobr>
</code>
<br/>
<code class="screen">
<nobr>AllowOverride None</nobr>
</code>
<br/>
<code class="screen">
<nobr>deny from all</nobr>
</code>
<br/>
<code class="screen">
<nobr>&lt;Location&gt;</nobr>
</code>
<br/>
<div class="screen"># All JSP will goes to worker1</div>
<code class="screen">
<nobr>JkMount /*.jsp worker1</nobr>
</code>
<br/>
<div class="screen"># All servlets goes to worker1</div>
<code class="screen">
<nobr>JkMount /*/servlet/ worker1</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
Use the mod_jk <b>
<font color="#333333">JkAutoAlias</font>
</b> directive to map all web application context directories 
into Apache's document space. 
</p>
<p class="section">
Attempts to access the WEB-INF or META-INF directories within a web application context 
or a Web Archive *.war within the Tomcat Host appBase (webapps) directory will fail with an 
<b class="code">HTTP 403, Access Forbidden</b>
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"># Static files in all Tomcat webapp context directories are served by apache</div>
<code class="screen">
<nobr>JkAutoAlias /var/tomcat3/webapps</nobr>
</code>
<br/>
<code class="screen">
<nobr>JkMount /*.jsp ajp13</nobr>
</code>
<br/>
<code class="screen">
<nobr>JkMount /*/servlet/ ajp13</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
<a name="Building mod_jk on Unix">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Building mod_jk on Unix</td>
</tr>
</table>
</a>
<p class="section">
The mod_jk build use the widely used configure system.
</p>
<a name="sub_Prepare your mod_jk configure from CVS">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Prepare your mod_jk configure from CVS</td>
</tr>
</table>
</a>
<p class="section">
To create jakarta-tomcat-connectors's autoconf script, you will need libtool 1.3.3 or higher, 
and autoconf 2.13 or newer.
</p>
<p class="section">
Those tools will not be required if you are just using a package downloaded from apache.org, 
they are only required for developers.
</p>
<p class="section">
To create the configure script just type :

<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./buildconf.sh</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
</p>
<br/>
<a name="sub_Using configure to build mod_jk">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Using configure to build mod_jk</td>
</tr>
</table>
</a>
<p class="section">Here's how to use configure to prepare mod_jk for building, just type: 
<pre class="section">
./configure [autoconf arguments] [jakarta-tomcat-connectors arguments]
</pre>
</p>
<p class="section">
You could set <b>
<font color="#333333">CFLAGS</font>
</b> and <b>
<font color="#333333">LDFLAGS</font>
</b> to add some platform specifics:
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">LDFLAGS=-lc ./configure -with-apxs=/home2/local/apache/bin/apxs</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
If you want to build mod_jk for Apache 1.3 and 2.0, you should 
<ul>
<li>
use configure and indicate Apache 1.3 apxs location (--with-apxs)
</li>
<li>
use make
</li>
<li>
copy the mod_jk binary to the apache modules location
</li>
<li>
make clean (to remove all previously compiled modules)
</li>
<li>
use configure and indicate Apache 2.0 apxs location,
</li>
<li>
then make.
</li>
</ul>

</p>
<br/>
<a name="sub_configure arguments">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>configure arguments</td>
</tr>
</table>
</a>
<p class="section">
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">Apache related parameters</td>
<td align="middle" valign="top" bgcolor="#039acc"/>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-apxs[=FILE]</td>
<td align="left" valign="top" bgcolor="#a0ddf0">FILE is the location of the apxs tool. Default is finding apxs in PATH.
It builds a shared Apache module. It detects automaticly the Apache version.
(2.0 and 1.3)</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-apache=DIR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">DIR is the path where apache sources are located.
The apache sources should have been configured before configuring mod_jk.
DIR is something like: /home/apache/apache_1.3.19
It builds a static Apache module.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--enable-EAPI</td>
<td align="left" valign="top" bgcolor="#a0ddf0">This parameter is needed when using Apache-1.3 and mod_ssl, otherwise you will get the error message:
"this module might crash under EAPI!" when loading mod_jk.so in httpd.
Not needed when --with-apxs has been used</td>
</tr>
</table>
<br/>
<table border="0">
<tr>
<td align="middle" valign="top" bgcolor="#039acc">JNI related parameters</td>
<td align="middle" valign="top" bgcolor="#039acc"/>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--enable-jni</td>
<td align="left" valign="top" bgcolor="#a0ddf0">Build the JNI worker and so the build process will require 
some informations about your Java Environment</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-java-home=DIR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">DIR is the  patch to the JDK root directory. Something like: /opt/java/jdk12</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-os-type=SUBDIR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">SUBDIR is the os-type subdirectory, 
  configure should guess it correctly.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-arch-type=SUBDIR</td>
<td align="left" valign="top" bgcolor="#a0ddf0">SUBDIR is the arch subdirectory, 
  configure should guess it correctly.</td>
</tr>
<tr>
<td align="left" valign="top" bgcolor="#a0ddf0">--with-java-platform=VAL</td>
<td align="left" valign="top" bgcolor="#a0ddf0">VAL is the Java platform 1 is 1.1.x and 2 is for 1.2 anf higher, 
  configure should guess it correctly.</td>
</tr>
</table>
</p>
<br/>
<a name="sub_Examples of configure use">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Examples of configure use</td>
</tr>
</table>
</a>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen">Apache 1.3 and 2.0 build</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/usr/sbin/apxs</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cp ./apache-1.3/mod_jk.so /usr/lib/apache</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make clean</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/usr/sbin/apxs2</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cp ./apache-2.0/mod_jk.so /usr/lib/apache2</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen">Apache 2.0 build with JNI support</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/opt/apache2/bin/apxs \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">--with-java-home=${JAVA_HOME} --with-java-platform=2 \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">--enable-jni</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen">Apache 1.3 build without JNI support</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/usr/sbin/apxs</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
<a name="Building mod_jk for Apache on Windows NT/2K/XP">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Building mod_jk for Apache on Windows NT/2K/XP</td>
</tr>
</table>
</a>
<p class="section">
The module was developed using Visual C++ version 6.0, so having this environment is a prerequisite 
if you want to perform a custom build.
</p>
<p class="section">
The steps that you need to take are:
</p>
<ul>
<li>
Change directory to the apache 1.3 or apache 2.0 source directory depending on your version of Apache.
</li>
<li>
If you want to build mod_jk for Apache 1.3, set an <b>
<font color="#333333">APACHE1_HOME</font>
</b> environment variable which points 
to where your Apache 1.3 is installed.
A mod_jk module for Apache 2.0 build will require <b>
<font color="#333333">APACHE2_HOME</font>
</b> environment variable to be set. 
</li>
<li>
Copy mod_jk.dll to Apache's modules directory.
</li>
</ul>
<p class="section">
An example on how to build mod_jk for Apache 1.3:
</p>
<p class="screendos">
<div align="center">
<table bgcolor="#000000" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#000000">
<div class="screendos">Set location for Apache 1.3 sources</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">set APACHE1_HOME=c:\apache13</b>
</nobr>
</code>
<br/>
<div class="screendos">Change directory to the mod_jk module for Apache 1.3</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">cd c:\home\apache\jk\native\apache-1.3</b>
</nobr>
</code>
<br/>
<div class="screendos">Build the sources using MSDEV</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">MSDEV mod_jk.dsp /MAKE ALL</b>
</nobr>
</code>
<br/>
<div class="screendos">Copy the dll to your apache modules directory</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">cp release\mod_jk.dll c:\apache13\modules\</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
An example on how to build mod_jk for Apache 2.0:
</p>
<p class="screendos">
<div align="center">
<table bgcolor="#000000" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#000000">
<div class="screendos">Set location for Apache 2.0 sources</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">set APACHE2_HOME=c:\apache20</b>
</nobr>
</code>
<br/>
<div class="screendos">Change directory to the mod_jk module for Apache 2.0</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">cd c:\home\apache\jk\native\apache-2.0</b>
</nobr>
</code>
<br/>
<div class="screendos">Build the sources using MSDEV</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">MSDEV mod_jk.dsp /MAKE ALL</b>
</nobr>
</code>
<br/>
<div class="screendos">Copy the dll to your apache modules directory</div>
<code>
<nobr>
<em class="screendos">c:\&gt;</em>
<b class="screendos">cp release\mod_jk.dll c:\apache20\modules\</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
If msdev is not in your path, enter the full path to msdev.exe. 
Also, ApacheCore.lib is expected to exist in the <b>
<font color="#333333">${APACHEX_HOME}\src\CoreD</font>
</b> and 
<b>
<font color="#333333">${APACHEX_HOME}\src\CoreR</font>
</b> directories before linking will succeed.
You will need to build enough of the Apache source to create these libraries.
This will build both release and debug versions of the redirector plug-in (mod_jk).
An alternative will be to open mod_jk.dsp in msdev and build it using the build menu.
</p>
<br/>
<a name="Building mod_jk for Apache on iSeries/OS400">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Building mod_jk for Apache on iSeries/OS400</td>
</tr>
</table>
</a>
<p class="section">
Since OS400 V4R5, iSeries (AS/400) has used Apache 2.0 as their primary web server, 
replacing the old IBM webserver.
It's now possible to build mod_jk on iSeries thanks to the help of the IBM 
Rochester Labs which has provided information and patches
to adapt mod_jk to OS400.
</p>
<p class="section">
You should have at least Apache 2.0.39, a C Compiler and IFS.
Apache 2.0.39 is provided with the most recent set of PTFs for the iSeries Apache
server, which can be found at <b>
<a href="http://www.ibm.com/servers/eserver/iseries/software/http/">
http://www.ibm.com/servers/eserver/iseries/software/http/</a>
</b>
</p>
<p class="section">
To configure mod_jk on iSeries use the CL source provided with the mod_jk source.
</p>
<ul>
<li>
Get the latest mod_jk source and untar it on a Windows or Unix boxes
</li>
<li>
Create a directory in IFS, ie /home/apache
</li>
<li>
Send the whole jk source directory to iSeries directory via FTP.
</li>
<li>
Then go to the iSeries command line :
</li>
</ul>
<p class="screen5250">
<div align="center">
<table bgcolor="#000000" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#000000">
<div class="screen5250">Create mod_jk library</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CRTLIB MOD_JK TEXT(&#145;Apache mod_jk tomcat connector module&#146;)</b>
</nobr>
</code>
<br/>
<div class="screen5250">Create service program source file</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CRTSRCPF MOD_JK/QSRVSRC TEXT(&#145;Service program source file&#146;)</b>
</nobr>
</code>
<br/>
<div class="screen5250">Create the CL build program source file</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CRTSRCPF FILE(MOD_JK/QCLSRC) TEXT(&#145;Build program source file&#146;)</b>
</nobr>
</code>
<br/>
<div class="screen5250">Edit the service program source file</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">STRSEU MOD_JK/QSRVSRC MOD_JK</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
In the edited file, specify that only jk_module should be exported :
<p class="screen5250">
<div align="center">
<table bgcolor="#000000" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#000000">
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250"> Columns   . . :    1  71     Edit                               MOD_JK/QSRVSRC </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250"> SEU==&gt;                                                                  MOD_JK </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">        *************** Beginning of data ************************************* </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">0001.00 STRPGMEXP PGMLVL(*CURRENT)                                              </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">0002.00 EXPORT SYMBOL("jk_module")                                              </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">0003.00 ENDPGMEXP                                                               </b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">        ****************** End of data **************************************** </b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
</p>
<p class="section">
You could start to build all the modules of mod_jk :
</p>
<p class="screen5250">
<div align="center">
<table bgcolor="#000000" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#000000">
<div class="screen5250">Copy the CL build program source from IFS</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CPYFRMSTMF FROMSTMF('/home/apache/jk/native/apache-2.0/bldjk.qclsrc') +</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen5250"> </em>
<b class="screen5250">TOMBR('/QSYS.LIB/MOD_JK.LIB/QCLSRC.FILE/BLDJK.MBR') MBROPT(*REPLACE)</b>
</nobr>
</code>
<br/>
<div class="screen5250">Build the CL build program</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CRTCLPGM PGM(MOD_JK/BLDJK) SRCFILE(MOD_JK/QCLSRC) TEXT('Apache mod_jk build program')</b>
</nobr>
</code>
<br/>
<div class="screen5250">Launch the build</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CALL MOD_JK/BLDJK</b>
</nobr>
</code>
<br/>
<div class="screen5250">If the build if successfull, copy the new mod_jk module</div>
<code>
<nobr>
<em class="screen5250">===&gt;</em>
<b class="screen5250">CRTDUPOBJ OBJ(MOD_JK) FROMLIB(MOD_JK) OBJTYPE(*SRVPGM) TOLIB(QHTTPSVR) NEWOBJ(MOD_JK)</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
Next, you should restart your Apache 2.0 server and enjoy this piece of OpenSource on iSeries.
</p>
<br/>
<a name="Building mod_jk for Apache on MacOS/X">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Building mod_jk for Apache on MacOS/X</td>
</tr>
</table>
</a>
<p class="section">
Mac OS X (10.2.x) build notes :
</p>
<p class="section">
Assuming that you are root :
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen">For Apache 1.3:</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/usr/sbin/apxs</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cd apache-1.3</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make -f Makefile.apxs</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cp mod_jk.so /etc/libexec/httpd</b>
</nobr>
</code>
<br/>
<div class="screen">For Apache 2.0:</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apxs=/usr/local/apache2/bin/apxs</b>
</nobr>
</code>
<br/>
<div class="screen">(you should point to the directory where you installed Apache 2.0)</div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cd apache-2.0</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make -f Makefile.apxs install</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<a name="Getting mod_jk linked statically with Apache">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="section" bgcolor="#525D76">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Getting mod_jk linked statically with Apache</td>
</tr>
</table>
</a>
<p class="section">
mod_jk allows to install mod_jk in the Apache source tree to get a statically
linked mod_jk. Having mod_jk in the httpd executable brings some performance
improvements. The configure option --with-apache prepare mod_jk to install it
in the Apache source tree.
The option --with-apache works both for Apache-1.3 and Apache-2.0.
The examples below show how to get mod_jk in the httpd process.
</p>
<a name="sub_Installation in Apache-2.0">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Installation in Apache-2.0</td>
</tr>
</table>
</a>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"> /home/apache20/httpd-2.0.43 is the directory where the httpd-2.0 sources
are located. </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apache=/home/apache20/httpd-2.0.43</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<div class="screen">Install the mod_jk library and other files in
/home/apache20/httpd-2.0.43/modules: </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make install</b>
</nobr>
</code>
<br/>
<div class="screen"> It is not possible to configure Apache directly because the config.m4 of mod_jk must
be added to the configure of httpd-2.0. </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cd /home/apache20/httpd-2.0.43</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">sh buildconf</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">configure ... --with-mod_jk</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make install</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
The enable-jk=share and enable-jk=static are not supported. --with-mod_jk only
allow static linking of mod_jk.
</p>
<br/>
<a name="sub_Installation in Apache-1.3">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" valign="top" class="subsection" bgcolor="#828DA6">
<img border="0" vspace="0" hspace="0" align="left" valign="top" src="../images/corner.gif"/>Installation in Apache-1.3</td>
</tr>
</table>
</a>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"> /home/apache/apache_1.3.27 is the directory where the apache-1.3 sources
are located. </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">./configure --with-apache=/home/apache/apache_1.3.27</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<div class="screen">Install the libjk library, mod_jk.c, includes and other files in
/home/apache/apache_1.3.27/src/modules/jk: </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make install</b>
</nobr>
</code>
<br/>
<div class="screen"> Configure in the Apache sources: </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">cd /home/apache/apache_1.3.27</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">configure ... --enable-module=dir --disable-shared=dir \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">              --activate-module=src/modules/jk/libjk.a \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">              --disable-shared=jk</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">make install</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<p class="section">
The --enable-shared=jk is also working and builds a dso file.
</p>
<p class="screen">
<div align="center">
<table bgcolor="#cccccc" cellpadding="2" cellspacing="0" border="1" width="80%">
<tr>
<td align="left" bgcolor="#cccccc">
<div class="screen"> Just change the configure in the Apache sources: </div>
<code>
<nobr>
<em class="screen">[user@host] ~ $ </em>
<b class="screen">configure ... --enable-module=dir --enable-shared=dir \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">              --activate-module=src/modules/jk/libjk.a \</b>
</nobr>
</code>
<br/>
<code>
<nobr>
<em class="screen"> </em>
<b class="screen">              --enable-shared=jk</b>
</nobr>
</code>
<br/>
</td>
</tr>
</table>
</div>
</p>
<br/>
<br/>
</td>
</tr>
</table>
</body>
</html>
